<template>
  <el-container>
    <el-header>
      <div>
        <img src="../../assets/img/img.png" alt="">
        <span>公共运动场馆预约系统 </span>
      </div>
      <el-menu :default-active="curIndex===null?'1': curIndex" class="el-menu-demo" mode="horizontal"
               active-text-color="#FFFF00" text-color="#fff" @select="select" router>
        <el-menu-item index="/userHome/order">场地预约</el-menu-item>
        <el-menu-item index="/userHome/eq">器材租赁</el-menu-item>
        <el-menu-item index="/userHome/myRent">我的租赁</el-menu-item>
        <el-menu-item index="/userHome/notice">
          <el-badge :is-dot="s" class="item"> 通知
          </el-badge>
        </el-menu-item>

        <el-menu-item index="/userHome/myOrder">我的订单</el-menu-item>
      </el-menu>
      <div>
        <span>欢迎你:{{ userName }} &nbsp; &nbsp; &nbsp;</span>
        <el-button type="warning" round @click="exit">退出</el-button>
        <el-dropdown>
          <el-avatar icon="el-icon-user-solid" class="el-dropdown-link"></el-avatar>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item>修改信息</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>
    </el-header>
    <el-container>
      <el-aside width="100px"></el-aside>
      <el-main>
        <router-view @show="show"></router-view>
      </el-main>
      <el-aside width="100px"></el-aside>
    </el-container>

  </el-container>
</template>

<script>

export default {
  name: "UserHome",
  created() {
    this.curIndex = sessionStorage.getItem("curIndex")
    this.userName = sessionStorage.getItem("name")
  },

  data() {
    return {
      curIndex: "",
      userName: "",
      s: false,
    }
  },


  methods: {
    saveState(index) {
      sessionStorage.setItem("curIndex", index)
    },
    exit() {
      sessionStorage.clear();
      this.$router.push("/");
    },
    select(index) {
      this.saveState(index);
    },
    show(show) {
      this.s = show;
    }

  }
}
</script>

<style scoped lang="less">
.el-container {
  height: 100%;
}

.el-header {
  background-color: #0099CC;
  display: flex;
  justify-content: space-between;
  padding-left: 0;
  align-items: center;
  color: white;
  font-size: 20px;

  > div {
    display: flex;
    align-items: center;

    span {
      margin-left: 15px;
    }
  }

}

.el-menu-demo {
  margin-right: 400px;
}

.el-main {
  background-color: #E9E4E4;
}

.el-aside {
  background-color: #E9E4E4;
}

img {
  width: 50px;
  border: 1px solid #eee;
  border-radius: 50%;

}

.el-menu-demo {
  background-color: #0099CC;
}

.el-menu-item.is-active {
  background-color: rgba(0, 0, 0, 0.1) !important;
}

.el-menu-item:hover {
  background-color: #0099CC !important;

}


.el-tab-pane {
  height: 60px;
}
</style>
